package com.ibeetl.cms.service;


import com.ibeetl.cms.dao.XxdActivitieDao;
import com.ibeetl.cms.entity.XxdActivitie;



import com.ibeetl.admin.core.service.CoreBaseService;
import com.ibeetl.admin.core.util.PlatformException;
import com.ibeetl.cms.entity.XxdItem;
import org.beetl.sql.core.SQLReady;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;

/**
 * XxdActivitie Service
 */

@Service
@Transactional
public class XxdActivitieService extends CoreBaseService<XxdActivitie>{

    @Autowired private XxdActivitieDao xxdActivitieDao;

    public PageQuery<XxdActivitie>queryByCondition(PageQuery query){
        PageQuery ret =  xxdActivitieDao.queryByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public PageQuery<XxdActivitie>queryBestByCondition(PageQuery query){
        PageQuery ret =  xxdActivitieDao.queryBestByCondition(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public List<XxdItem>queryBestItems(){
        List<XxdItem> list =  xxdActivitieDao.queryBestItems();
        return list;
    }

    public PageQuery<XxdItem>showActivitieSelectItem(PageQuery query){
        PageQuery ret =  xxdActivitieDao.showActivitieSelectItem(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public PageQuery<XxdItem>showBestSaleItem(PageQuery query){
        PageQuery ret =  xxdActivitieDao.showBestSaleItem(query);
        queryListAfter(ret.getList());
        return ret;
    }

    public void batchDelXxdActivitie(List<Long> ids){
        try {
            xxdActivitieDao.batchDelXxdActivitieByIds(ids);
        } catch (Exception e) {
            throw new PlatformException("批量删除失败", e);
        }
    }

//    public int getById(String id){
//        return sqlManager.execute(new SQLReady("select * from device_info d where d.del = '0' and d.oem_id = ? and d.user_id = ? and d.sn between ? and ?"
//                ,deviceInfo.getOemId(),deviceInfo.getUserId(),deviceInfo.getStartSn(),deviceInfo.getEndSn()),DeviceInfo.class).size();
//    }
    public int removeBest(){
        return xxdActivitieDao.removeBest();
    }

}